package com.zhangyongyi.carhome.adapter.Forum;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.zhangyongyi.carhome.R;

import java.util.ArrayList;

/**
 * Created by dllo on 16/1/19.
 */
public class ForumAdapter extends FragmentPagerAdapter {
    private ArrayList<Fragment> datas;
    private Context context;
    String[] titles = {"精选日报", "热帖"};


    public ForumAdapter(FragmentManager fm, ArrayList<Fragment> datas, Context context) {
        super(fm);
        this.datas = datas;
        this.context = context;
    }

    @Override
    public Fragment getItem(int position) {
        return datas.get(position);
    }

    @Override
    public int getCount() {
        return datas.size();
    }
    //tablayout和viewpager结合之后,创建底部title使用的方法
    @Override
    public CharSequence getPageTitle(int position) {

        return null;
    }

    public View getTabView(int position) {
        View view = LayoutInflater.from(context).inflate(R.layout.tab_hot, null);
        TextView textview = (TextView) view.findViewById(R.id.tv_hot_tab);
        textview.setText(titles[position]);
        return view;
    }

}
